{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "URL: http://bokeh.pydata.org/en/latest/docs/gallery/lorenz.html\n",
    "\n",
    "Most examples work across multiple plotting backends, this example is also available for:\n",
    "\n",
    "* [Bokeh - lorenz_attractor_example](../bokeh/lorenz_attractor_example.ipynb)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import holoviews as hv\n",
    "hv.extension('matplotlib')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Declare the data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from scipy.integrate import odeint\n",
    "\n",
    "sigma = 10\n",
    "rho = 28\n",
    "beta = 8.0/3\n",
    "theta = 3 * np.pi / 4\n",
    "\n",
    "def lorenz(xyz, t):\n",
    "    x, y, z = xyz\n",
    "    x_dot = sigma * (y - x)\n",
    "    y_dot = x * rho - x * z - y\n",
    "    z_dot = x * y - beta* z\n",
    "    return [x_dot, y_dot, z_dot]\n",
    "\n",
    "initial = (-10, -7, 35)\n",
    "t = np.arange(0, 100, 0.006)\n",
    "\n",
    "solution = odeint(lorenz, initial, t)\n",
    "\n",
    "x = solution[:, 0]\n",
    "y = solution[:, 1]\n",
    "z = solution[:, 2]\n",
    "xprime = np.cos(theta) * x - np.sin(theta) * y\n",
    "\n",
    "lorenzian = hv.Overlay([hv.Path(d) for d in zip(np.array_split(xprime, 7), np.array_split(z, 7))])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Plot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "lorenzian(style={'Path': dict(color=hv.Palette('Blues'), linewidth=1)})"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
